package com.whc.handler;

import com.whc.exception.BaseException;
import com.whc.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 韦红材
 * @ClassName GlobalExceptionHandler
 * @data 2024/10/21 17:59
 * @Version V1.0
 **/
//全局异常处理器
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler
    public Result ExceptionHandler(BaseException ex){
        log.error("异常信息：{}",ex.getMessage());
        return Result.error(ex.getMessage());
    }
}
